package com.wlr.study.leetcode;

import java.util.Comparator;
import java.util.HashMap;
import java.util.Map;
import java.util.Stack;

public class LeetCode300 {

    public int lengthOfLIS(int[] nums) {
        Map<Integer, Integer> map = new HashMap<>();
        int i = 0, j = 0;
        while (i < nums.length) {
            Stack<Integer> stack = new Stack<>();
            stack.push(nums[i]);
            while (j < nums.length) {
                if (nums[j] > stack.peek()) {
                    stack.push(nums[j]);
                }
                j++;
            }
            map.put(i, stack.size());
            i++;
            j = i;
        }
        return map.values().stream().max(Comparator.naturalOrder()).get();
    }

    public static void main(String[] args) {
        LeetCode300 leetCode300 = new LeetCode300();
        System.out.println(leetCode300.lengthOfLIS(new int[]{10, 9, 2, 5, 3, 7, 101, 18}));
    }
}
